
package ar.com.ctrln.services.ticket;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ar.com.ctrln.persistence.dao.ticket.TicketDao;
import ar.com.ctrln.persistence.dao.ticket.TipoTicketDao;
import ar.com.ctrln.persistence.model.ticket.Ticket;
import ar.com.ctrln.persistence.model.ticket.TipoTicket;

@Service("gestorTicket")
public class GestorTicket {

	@Autowired
	private TipoTicketDao tipoTicketDao;
	
	@Autowired
	private TicketDao ticketDao;
		
	////////ABM TICKETS////////
	public Ticket nuevoTicket(){
		return new Ticket();
	}
	
	public void guardar(Ticket ticket){
		ticketDao.save(ticket);
	}
		
	public void actualizar(Ticket ticket){
		ticketDao.update(ticket);
	}
		
	//////LISTADOS TICKETS////////
	public List<Ticket> listarTickets(){
		final List<Ticket> list = ticketDao.getList();
		return list;
	}
	
	public List<Ticket> listarTicketsOrder(){
		final List<Ticket> list = ticketDao.ticketsOrder();
		return list;
	}
	
	public List<Ticket> listarTicketsEmisor(long id){
		final List<Ticket> list = ticketDao.ticketsByEmisor(id);
		return list;
	}
		
	public Ticket getTicket(long id){
		return ticketDao.get(id);
	}
		
	public List<TipoTicket> listarTipoTickets(){
		return tipoTicketDao.getList();
	}

	public TipoTicket getTipoTicket(String tipo) {
		
		return tipoTicketDao.getTipoTicket(tipo);
	}
	
}

